#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int main()
{
	char arr1[100] = { 0 };
	gets(arr1);
	char arr2[100] = { 0 };
	char* p1 = arr1;
	int k = 0;
	scanf("%d", &k);
	int sz = strlen(arr1);
	for (int i = 0; i < sz; i++) {
		arr2[i] = arr1[i];
	}
	char* p2 = arr2;
	int n = k % sz;
	for (int i = sz-1; i >= 0; i--) {
		int x = (n + i) % sz;
			*(p1 + i) = *(p2 + x);
	}
	for (int i = 0; i < sz; i++) {
		printf("%c", arr1[i]);
	}
	return 0;
}